package com.oceansoft.core.jxkh.controller;

import com.hui.platform.system.exception.HuiException;
import com.oceansoft.core.common.constant.Constant;
import com.oceansoft.core.domain.SysUser;
import com.oceansoft.core.jxkh.domain.Signin;
import com.oceansoft.core.jxkh.service.ISigninService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by zhuya on 2017-11-01.
 */
@Controller
@RequestMapping("/sign")
public class SigninController {
    @Resource
    private ISigninService signinService;
    //签到，签退
    @RequestMapping(value="/signin")
    public void signIn(HttpServletRequest request,ModelMap modelMap) {
        SysUser user = (SysUser) request.getSession().getAttribute(Constant.LOGIN_USER);
        String type=request.getParameter("type");
        String time ="";
        try {
            time = signinService.signIn(user.getPoliceNum());
        } catch (HuiException e) {
            e.printStackTrace();
        }
        modelMap.addAttribute("time",time);
    }
    @RequestMapping(value="signinfo")
    public void signinfo(HttpServletRequest request,ModelMap modelMap) {
        SysUser user = (SysUser) request.getSession().getAttribute(Constant.LOGIN_USER);
        String workdate = request.getParameter("workdate");
        //根据workdate获取当日的签到信息
        Signin signin = signinService.findByPoliceNumAndDate(user.getPoliceNum(),workdate);
        modelMap.addAttribute("signin",signin);
    }
}


